import { Routes, Route, NavLink } from "react-router-dom";
// import "./style.css";

const Home = () => {
  return <div>home页面</div>;
};

const About = () => {
  return <div>about页面</div>;
};

const App = () => {
  return (
    <>
      <h3>router-v6-navlink</h3>
      {/* 导航高亮的写法一样，也是使用NavLink，自动地加上active的类名 */}
      <ul>
        <li>
          <NavLink
            to="/home"
            style={({ isActive }) => {
              console.log(isActive);
              return {
                color: isActive ? "red" : "",
              };
            }}
          >
            home
          </NavLink>
        </li>
        <li>
          <NavLink to="/about">about</NavLink>
        </li>
      </ul>

      <hr />

      <Routes>
        <Route path="/home" element={<Home />}></Route>
        <Route path="/about" element={<About />}></Route>
      </Routes>
    </>
  );
};

export default App;
